package com.aischool.utils;

public class StringUtil {
	
	/**
	 * 去除字符串首尾出现的某个字符.
	 */
	public static String trim(String source,char c){
		return source.replaceAll("^\\"+c+"+|\\"+c+"+$", "");
//		boolean beginIndexFlag = true;
//		boolean endIndexFlag = true;
//		do{
//			int beginIndex = source.indexOf(element) == 0 ? 1 : 0;
//			int endIndex = source.lastIndexOf(element) + 1 == source.length() ? source.lastIndexOf(element) : source.length();
//			source = source.substring(beginIndex, endIndex);
//			beginIndexFlag = (source.indexOf(element) == 0);
//			endIndexFlag = (source.lastIndexOf(element) + 1 == source.length());
//		} while (beginIndexFlag || endIndexFlag);
//		return source;
	}
}
